package it.evento.utils.genpage;

/**
 *
 * @author Ilo
 */
public class RowCell {
    
    private String title;
    private String content;
    private String width;
    private String link;
    private long stars;
    private long ratesNumber;
    private String id;

    public RowCell() {
        resetAll();
    }
    
    public RowCell setTitle(String title) {
        this.title = title;
        return this;
    }
    
    public RowCell setContent(String content) {
        this.content = content;
        return this;
    }
    
    public RowCell setWidth(String width) {
        this.width = width;
        return this;
    }
    
    public RowCell setLink(String link) {
        this.link = link;
        return this;
    }
    
    public RowCell setStars(long stars) {
        this.stars = stars;
        return this;
    }
    
    public RowCell setRatesNumber(long ratesNumber) {
        this.ratesNumber = ratesNumber;
        return this;
    }
    
    public RowCell setID(String id) {
        this.id = id;
        return this;
    }
    
    public String print() {
        String ret = "";
        
        ret += "<div class='evento-layout-cell layout-item-2' style='width:" + this.width + "' >";
        if(this.title != null)
            ret += (this.link!=null ? "<a href='" + this.link + "'>" : "") + "<h3>" + this.title + "</h3>" + (this.link!=null ?"</a>" : "");
        if(this.stars != -1) {
            ret += "<div class='evento evento-metadata-icons'>";
                ret += "<span class='evento-staricon' id='starsfor-" + this.id + "' data-score='" + this.stars + "'></span>";
                ret += "<span id='votesfor-" + this.id + "'>" + this.ratesNumber + " vot" + (this.ratesNumber==1 ? "o" : "i") + ".</span>";
            ret += "</div>";
        }
        ret += "<p>" + this.content + "</p>";
        ret += "</div>";
        
        resetAll();
        
        return ret;
    }
    
    private void resetAll() {
        this.title = null;
        this.content = "";
        this.width = "100%";
        this.link = null;
        this.stars = -1;
        this.ratesNumber = 0;
        this.id = null;
    }
    
}
